import { ogImage, OG_SIZE, OG_CONTENT_TYPE } from '@/lib/og'; import { getCancerBySlug, getCounters } from '@/lib/queries/cancers'; import { fmtInt, humanize } from '@/lib/format'; export const alt = 'CancerIndex cancer profile'; export const size = OG_SIZE; export const contentType = OG_CONTENT_TYPE; export const revalidate = 3600; /** Share image of a cancer page: name, entity type, NCIt code and the deterministic counters (never estimates). */ export default async function Image({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const c = await getCancerBySlug(slug); if (!c) return ogImage({ kicker: 'Cancer', title: 'Entity not found', subtitle: slug }); const k = await getCounters(c.id); const facts = [ k?.active_trial_count ? { label: 'active trials', value: fmtInt(k.active_trial_count) } : null, k?.approved_drug_count ? { label: 'approved drugs', value: fmtInt(k.approved_drug_count) } : null, k?.evidence_count ? { label: 'evidence items', value: fmtInt(k.evidence_count) } : null, k?.publication_count_5y ? { label: 'publications · 5 y', value: fmtInt(k.publication_count_5y) } : null, ].filter((f): f is { label: string; value: string } => !!f); return ogImage({ kicker: `${humanize(c.entity_type)}${c.primary_ncit_code ? ` · NCIt ${c.primary_ncit_code}` : ''}`, title: c.canonical_name, subtitle: c.description ?? (c.short_name && c.short_name !== c.canonical_name ? c.short_name : `Taxonomy, statistics, genomics, evidence, drugs, trials and rankings for ${c.canonical_name}.`), facts, sourcesNote: facts.length ? 'ClinicalTrials.gov · openFDA / Health Canada / EMA · CIViC · PubMed' : null, }); }